Skip to content

Rework WiFiClient #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 1, 2017
Merged

Rework WiFiClient #238

merged 4 commits into from
Mar 1, 2017

Conversation

schrod
Copy link
Contributor

@schrod schrod commented Feb 26, 2017

Rework WiFiClient to correct error where making a copy of a WiFiClient object resulted in the socket being closed prematurely.

Added loop and select to write to handle/prevent EAGAIN errors.

Rework WiFiClient to correct error where making a copy of a WiFiClient object resulted in the socket being closed prematurely.

Added loop and select to write to handle/prevent EAGAIN errors.
@me-no-dev
Copy link
Member

There are generally two ways to tackle issues like that. I would rather use shared pointer which will manage the state on it's own, will clean the code and you will not have to worry to ref/unref count.
Please do have Added loop and select to write to handle/prevent EAGAIN errors. in a separate PR as the change has no relation to the rest.

@schrod
Copy link
Contributor Author

schrod commented Feb 27, 2017

Interesting, I hadn't been aware of shared pointers (I'm mostly a C developer). I agree that looks like it will be a cleaner implementation, I'll work on that change and move the changes to write to a separate PR.

Rework changes to utilize shared_ptr rather than manually maintaining reference count. 

Revert changes to write
Copy link
Member

@me-no-dev me-no-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice :) just a few comments :)

#include "Arduino.h"
#include "Client.h"
#include <memory>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move the whole class in the CPP and only forward declare it here. It's private really and users do not need to bother with it.

@@ -199,52 +165,21 @@ int WiFiClient::read()

size_t WiFiClient::write(const uint8_t *buf, size_t size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to sync this code now with the one that I already merged :)

@@ -69,21 +87,26 @@ class WiFiClient : public Client
return !this->operator==(rhs);
};

int fd()
int fd() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go into the CPP

Conflicts:
	libraries/WiFi/src/WiFiClient.cpp
Move WiFiClientSocketHandle and fd() into WiFiClient.cpp
@me-no-dev me-no-dev merged commit f0fc28f into espressif:master Mar 1, 2017
@me-no-dev
Copy link
Member

great work :) maybe you want to look at WiFiClientSecure?

@schrod
Copy link
Contributor Author

schrod commented Mar 2, 2017

Yup, looks like WiFiClientSecure has the same issue. I'll see what I can do.

@me-no-dev
Copy link
Member

udp probably suffers from that same thing :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants